-
Notifications
You must be signed in to change notification settings - Fork 80
feat(patterns): M.containerHas(el,n) to support want patterns #2710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f2ec8de to
143ba1f
Compare
26dc7de to
9d8d743
Compare
d4a686e to
efb4c47
Compare
|
Meta-commentary:
|
abfc1f7 to
6998c50
Compare
Chris-Hibbert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @gibson042's suggestions on naming. Additionally, I wouldn't expect there to be many calls, so a long name is fine here.
|
I went with |
|
As for the second, my whole approach with the pair of PRs is to get unstuck by adding minimal complexity needed to get enough expressiveness to cover our expected actual needs. We can always expand the patterns we accept in these roles later if
|
7aced6c to
8b3927b
Compare
|
I am ready to squash and merge. But in the OP (and at Show&Tell) I said
I'd like to appeal this to my reviewers. The existence of this new feature will probably not cause the problem yet. The use of it by agoric-sdk will cause the problem. So I'd like to proceed so it gets in the next endo release, enabling a smoother experience of local testing and debugging of Agoric/agoric-sdk#10952 Reviewers, waddaya think? I'll wait a day for at least one yes and no objections. |
AFAICT, such an expansion would be awkward unless it takes the form of an entirely new name, because e.g. |
|
I was not thinking of either a new name nor a new pattern. Rather, using That's what I meant by "We can always expand the patterns we accept in these roles later". The "we accept" is more precisely " |
Given that locally one can have second checkouts of the two repos and (And for remote testing Agoric/agoric-sdk#10952 is already using |
|
Thanks @turadg , I will stick with the original commitment. Since it is otherwise ready to go, I'm putting it in draft to protect me from myself ;) |
2250713 to
f026934
Compare
|
We have now decided to move forward with #2008 (thanks @mhofman @gibson042 ), so this PR can now be merged. |
@kriskowal suggests So how do y'all @gibson042 @kriskowal @turadg @Chris-Hibbert @mhofman feel about |
|
I still think the name needs either a prefix or a suffix indicating its restriction to collection membership testing. Bare EDIT: |
|
Thanks @gibson042 . Ok @kriskowal , we're going with |
I agree that At this point, I’m not holding up the release on continued discussion, but do let me know if this is a compelling argument. |
|
I think I could live with a single-element |
For multi-element, I would favor |
|
The pattern we're talking about has a single subpattern (the elementPattern) and a positive nat count, but most certainly is not about a single member of the collection. In fact, if the count is >= 2 then is cannot be satisfied by a single member of the collection. That's why the earlier suggestion Is it unclear what the pattern means? |
|
I mention all this because |
|
In any case, I agree this is not about to converge, so we should go ahead with |
|
My above use of "single-element" and "multi-element" should instead be read as "single-pattern" and "multi-pattern". As noted in the original comment, I do anticipate eventual introduction of multi-pattern composites to express more intricate wants. |
|
Is there a string contains or array contains? I could not find them. Where? |
|
ECMAScript String and Array/%TypedArray% Map/Set/WeakMap/WeakSet But in Endo, a pattern function doesn't have the context of a prototype and so ought to indicate by name the domain of inputs for which it is applicable and corresponding predicate behavior over them—and they generally succeed at that! ( |
Closes: #XXXX
Refs: #2002 #2008 #2113 #1739 Agoric/agoric-sdk#10952
Description
This PR adds a new
M.containerHas(elementPatt, positiveBigint)matcher, and exportedcontainerHasSplitfunction. This is motivated to support Agoric/agoric-sdk#10952 , which introduces a minimal form of want pattern in terms ofM.containerHas.Security Considerations
none
Scaling Considerations
Might help due to early termination of the split operations, which Agoric/agoric-sdk#10952 uses for
AmountMath.isGTE.Documentation Considerations
Already doc-documents
M.containerHasin the types.js file forM. That's probably good enough for this PR. The interesting documentation will be explaining want patterns in Agoric/agoric-sdk#10952Testing Considerations
Added tests for
M.containerHasCompatibility Considerations
The reason to postpone merging this PR until decisions are made on #2008 is that this PR will further expose
rankOrderin the API, amplifying the danger that changing the string order will cause surprising observable changes.Upgrade Considerations
This PR itself does not introduce any BREAKING changes or Upgrade issues.
NEWS.mdfor user-facing changes.